package com.shaomengjie.smjmvp.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.shaomengjie.smjmvp.R;

/**
 * Created by shaomengjie on 2017/4/20.
 */

public class GuidePagerAdapter extends PagerAdapter {
    private int[] images;
    private Context mContext;
    public GuidePagerAdapter() {
    }

    public GuidePagerAdapter(int[] images, Context mContext) {
        this.images = images;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return images.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.activity_guide_bg,null);
        ImageView imageView = (ImageView) view.findViewById(R.id.mGuideImageView);
        imageView.setImageResource(images[position]);
        return super.instantiateItem(container, position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }
}
